package com.loong.nnm.impl;

import com.loong.nnm.entity.pg.LAG;
import com.loong.nnm.entity.pg.PG;
import com.loong.nnm.services.PGServices;
import com.loong.nnm.utils.XmlBuilderUtils;
import net.juniper.netconf.XML;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("PGServices")
public class PGImpl implements PGServices {

    private static final String PATH_NAME = "xmlns";
    private static final String PATH_VALUE = "urn:ccsa:yang:acc-protection-group";

//    @Resource
    private XmlBuilderUtils xmlBuilderUtils;
//    @Resource
    private NetconfToolImpl netconfTool = new NetconfToolImpl();

    private String get(String node, String module) {
        //组装报文，需要查询的子树进行过滤
        XML content = xmlBuilderUtils.getXMlCoat();
        XML me = content.append(module);
        me.setAttribute(PATH_NAME, PATH_VALUE);
        System.out.println(content);
        //下发请求，并返回报文
        return netconfTool.get(node, content);
    }

    @Override
    public String getPGs(String node) {
        return get(node,"pgs");
    }

    @Override
    public String setPGS(String node, PG pg) {
        return null;
    }

    @Override
    public String switchPG(String node, String json) {
        return null;
    }

    @Override
    public String deletePG(String node, int pgId) {
        return null;
    }

    @Override
    public String getLAGs(String node) {
        return get(node,"lagPGs");
    }

    @Override
    public String setLAGS(String node, LAG lag) {
        return null;
    }

    @Override
    public String deleteLAG(String node, int lagId) {
        return null;
    }
}
